﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using DTO;


namespace DAO
{
    [Serializable]
    public class SoDaiLyToiDaCuaMotQuanDAO
    {
        #region 1.Retrieving
        public static List<SoDaiLyToiDaCuaMotQuanDTO> GetSoDaiLyToiDa()
        {
            List<SoDaiLyToiDaCuaMotQuanDTO> listSoDaiLy = new List<SoDaiLyToiDaCuaMotQuanDTO>();

            DataTable dt = SqlDataConnectHelper.ExecuteQuery("usp_SelectSoDaiLyToiDaCuaMotQuansAll");
            SoDaiLyToiDaCuaMotQuanDTO numDaily = new SoDaiLyToiDaCuaMotQuanDTO();
            numDaily.SoDaiLyToiDa = int.Parse(dt.Rows[0]["sodailytoidacuamotquan"].ToString());
            listSoDaiLy.Add(numDaily);

            return listSoDaiLy;
        }
        #endregion
        #region 2.Updating
        public static bool UpdateSoDaiLyToiDa(SoDaiLyToiDaCuaMotQuanDTO soDaiLy)
        {
            bool isSucessful = false;
            List<SqlParameter> listParam = new List<SqlParameter>();
            listParam.Add(new SqlParameter("@sodailytoidacuamotquan", soDaiLy.SoDaiLyToiDa));
            int n = SqlDataConnectHelper.ExecuteNoneQuery("usp_UpdateSoDaiLyToiDaCuaMotQuan", listParam);
            if (n == -1)
            {
                isSucessful = true;
            }
            return isSucessful;
        }
        #endregion

    }
}
